package mua.core.operation.other;

import mua.core.interpreter.Global;
import mua.core.value.FunctionBody;
import mua.core.value.List;
import mua.core.value.MuaValue;
import mua.core.value.Word;

import java.util.ArrayList;

public class PoAll {
    public static MuaValue run(FunctionBody functionBody) {
        ArrayList<MuaValue> list = new ArrayList<>();
        //返回全局变量的list
        if(functionBody==null){
            for(String key: Global.globalVariable.keySet()){
                list.add(new Word(key));
            }
        }
        //返回当前名字空间的变量的list
        else{
            for(String key:functionBody.getLocalVariable().keySet()){
                list.add(new Word(key));
            }
        }
        return new List(list);
    }
}
